/**
 * Author(s): xuming.Wong <xuming.Wong@gmail.com>
 */

#include "LightObject.h"
#include "SceneObject.h"

namespace PQEngine
{
	LightObject::LightObject(SceneObject* sceneObject,LightType lightType)
		: GameObject(sceneObject,GAME_OBJECT_LIGHT)
	{
		assert(sceneObject);

		Ogre::Light::LightTypes type=(Ogre::Light::LightTypes)lightType;
		Ogre::Light* light=_sceneObject->getSceneManager()->createLight();
		light->setType(type);

		
		_lightComponent=new LightComponent(light);
		_lightComponent->attach(this);
		
		switch(type){
			case Ogre::Light::LT_POINT:
				this->setName("Point Light");
				break;
			case Ogre::Light::LT_DIRECTIONAL:
				this->setName("Directional Light");
				break;
			case Ogre::Light::LT_SPOTLIGHT:
				this->setName("Spot Light");
				break;
			default:
				break;
		}

	}

	void LightObject::setType(LightType type)
	{
		if(_lightComponent){
			_lightComponent->setType(type);
		}
	}

	void LightObject::setDirection(const Ogre::Vector3& direction)
	{
		if(_lightComponent){
			_lightComponent->setDirection(direction);
		}
	}

	void LightObject::setDiffuseColor(const Ogre::ColourValue &color)
	{
		if(_lightComponent){
			_lightComponent->setDiffuseColor(color);
		}
	}

	void LightObject::setSpecularColor(const Ogre::ColourValue &color)
	{
		if(_lightComponent){
			_lightComponent->setSpecularColor(color);
		}
	}

}
